package org.example.testdemo.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.example.testdemo.mapper.AccountingIntervalMapper;
import org.example.testdemo.pojo.AccountingInterval;
import org.example.testdemo.service.AccountingIntervalService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AccountingIntervalServiceImpl implements AccountingIntervalService {

    @Resource
    private AccountingIntervalMapper intervalMapper;

    /**
     * 使用区间id查询区间信息
     * @param intervalId 区间id
     * @return 返回区间信息
     */
    @Override
    public AccountingInterval findByIntervalId(String intervalId) {
        QueryWrapper<AccountingInterval> intervalQueryWrapper = new QueryWrapper<>();
        intervalQueryWrapper.eq("intervalId",intervalId);
        return intervalMapper.selectOne(intervalQueryWrapper);
    }

    /**
     * 获取所有区间信息
     * @return 返回一个区间信息集合
     */
    @Override
    public List<AccountingInterval> findByAll() {
        return intervalMapper.selectList(null);
    }
}
